package qianmo.system.service.impl;

import java.util.List;
import qianmo.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import qianmo.system.mapper.QuestionPracticeRecordMapper;
import qianmo.system.domain.QuestionPracticeRecord;
import qianmo.system.service.IQuestionPracticeRecordService;

/**
 * 题目练习记录Service业务层处理
 * 
 * @author qianmo
 * @date 2025-03-23
 */
@Service
public class QuestionPracticeRecordServiceImpl implements IQuestionPracticeRecordService 
{
    @Autowired
    private QuestionPracticeRecordMapper questionPracticeRecordMapper;

    /**
     * 查询题目练习记录
     * 
     * @param id 题目练习记录主键
     * @return 题目练习记录
     */
    @Override
    public QuestionPracticeRecord selectQuestionPracticeRecordById(Long id)
    {
        return questionPracticeRecordMapper.selectQuestionPracticeRecordById(id);
    }

    /**
     * 查询题目练习记录列表
     * 
     * @param questionPracticeRecord 题目练习记录
     * @return 题目练习记录
     */
    @Override
    public List<QuestionPracticeRecord> selectQuestionPracticeRecordList(QuestionPracticeRecord questionPracticeRecord)
    {
        return questionPracticeRecordMapper.selectQuestionPracticeRecordList(questionPracticeRecord);
    }

    /**
     * 新增题目练习记录
     * 
     * @param questionPracticeRecord 题目练习记录
     * @return 结果
     */
    @Override
    public int insertQuestionPracticeRecord(QuestionPracticeRecord questionPracticeRecord)
    {
        questionPracticeRecord.setCreateTime(DateUtils.getNowDate());
        return questionPracticeRecordMapper.insertQuestionPracticeRecord(questionPracticeRecord);
    }

    /**
     * 修改题目练习记录
     * 
     * @param questionPracticeRecord 题目练习记录
     * @return 结果
     */
    @Override
    public int updateQuestionPracticeRecord(QuestionPracticeRecord questionPracticeRecord)
    {
        questionPracticeRecord.setUpdateTime(DateUtils.getNowDate());
        return questionPracticeRecordMapper.updateQuestionPracticeRecord(questionPracticeRecord);
    }

    /**
     * 批量删除题目练习记录
     * 
     * @param ids 需要删除的题目练习记录主键
     * @return 结果
     */
    @Override
    public int deleteQuestionPracticeRecordByIds(Long[] ids)
    {
        return questionPracticeRecordMapper.deleteQuestionPracticeRecordByIds(ids);
    }

    /**
     * 删除题目练习记录信息
     * 
     * @param id 题目练习记录主键
     * @return 结果
     */
    @Override
    public int deleteQuestionPracticeRecordById(Long id)
    {
        return questionPracticeRecordMapper.deleteQuestionPracticeRecordById(id);
    }

    @Override
    public List<QuestionPracticeRecord> getRecordsByQuestionAndStudent(Long questionId, Long studentId) {
        return questionPracticeRecordMapper.selectRecordsByQuestionAndStudent(questionId, studentId);
    }
}
